package com.legal.aid.system.service.impl;

import java.util.List;

import com.legal.aid.common.core.domain.model.LoginUser;
import com.legal.aid.common.utils.DateUtils;
import com.legal.aid.common.utils.SecurityUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.legal.aid.system.mapper.CaseMapper;
import com.legal.aid.system.domain.Case;
import com.legal.aid.system.service.ICaseService;

/**
 * 经典案例Service业务层处理
 * 
 * @author ruoyi
 * @date 2025-05-27
 */
@Service
public class CaseServiceImpl implements ICaseService 
{
    @Autowired
    private CaseMapper caseMapper;

    /**
     * 查询经典案例
     * 
     * @param caseId 经典案例主键
     * @return 经典案例
     */
    @Override
    public Case selectZCaseByCaseId(Long caseId)
    {
        return caseMapper.selectZCaseByCaseId(caseId);
    }

    /**
     * 查询经典案例列表
     * 
     * @param zCase 经典案例
     * @return 经典案例
     */
    @Override
    public List<Case> selectZCaseList(Case zCase)
    {
        return caseMapper.selectZCaseList(zCase);
    }

    /**
     * 新增经典案例
     * 
     * @param zCase 经典案例
     * @return 结果
     */
    @Override
    public int insertZCase(Case zCase)
    {
        LoginUser loginUser = SecurityUtils.getLoginUser();
        zCase.setCreatedBy(loginUser.getUsername());
        zCase.setCreateTime(DateUtils.getNowDate());
        return caseMapper.insertZCase(zCase);
    }

    /**
     * 修改经典案例
     * 
     * @param zCase 经典案例
     * @return 结果
     */
    @Override
    public int updateZCase(Case zCase)
    {
        LoginUser loginUser = SecurityUtils.getLoginUser();
        zCase.setUpdatedBy(loginUser.getUsername());
        zCase.setUpdateTime(DateUtils.getNowDate());
        return caseMapper.updateZCase(zCase);
    }

    /**
     * 批量删除经典案例
     * 
     * @param caseIds 需要删除的经典案例主键
     * @return 结果
     */
    @Override
    public int deleteZCaseByCaseIds(Long[] caseIds)
    {
        return caseMapper.deleteZCaseByCaseIds(caseIds);
    }

    /**
     * 删除经典案例信息
     * 
     * @param caseId 经典案例主键
     * @return 结果
     */
    @Override
    public int deleteZCaseByCaseId(Long caseId)
    {
        return caseMapper.deleteZCaseByCaseId(caseId);
    }
}
